package fh.util;

import java.io.File;  
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;  
import java.util.Map;  
import java.util.Properties;  

public class ResourceLoader {
	 private static ResourceLoader loader = new ResourceLoader();  
	    private static Map<String, Properties> loaderMap = new HashMap<String, Properties>();  
	  
	    private ResourceLoader() {  
	    }  
	  
	    public static ResourceLoader getInstance() {  
	        return loader;  
	    }  
	      
	    public Properties getPropFromProperties(String fileName) throws Exception {  
	          
//	        Properties prop = loaderMap.get(fileName);  
	        
	        Properties prop = new Properties();  
	        
//	        if (prop != null) {  
//	            return prop;  
//	        }  
	        
	        InputStream is=this.getClass().getResourceAsStream("/properties/" + fileName);
            prop.load(is);
            is.close();
//	        String filePath = "";  
//	        String configPath = System.getProperty("configurePath");  
//	  
//	        if (configPath == null) {  
//	        filePath = this.getClass().getResourceAsStream(fileName).  
	        
//	        System.out.println(filePath);
//	        } else {  
//	            filePath = configPath + "/" + fileName;  
//	        }  
//	        prop = new Properties();  
//	        prop.load(new FileInputStream(new File(filePath)));  
//	  
//	        loaderMap.put(fileName, prop);  
	        return prop;  
	    }  
}
